package com.polaris.live.adapter.diamond

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterDiamondPopupBinding
import com.polaris.live.resp.bean.DiamondSelectBean

/**
 * DiamondPopupAdapter
 *
 * @author Created by 半仙 on 2023/10/28/028 14:06
 */
class DiamondPopupAdapter :
    BaseBindingAdapter<AdapterDiamondPopupBinding, DiamondSelectBean>() {

    private var selectPosition = 0

    override fun convert(
        holder: VBViewHolder<AdapterDiamondPopupBinding>,
        item: DiamondSelectBean
    ) {
        holder.vb.apply {
            itemImg.setImageResource(item.imgRes)
            itemText.text = item.content
            val index = holder.absoluteAdapterPosition
            if (selectPosition == index) {
                shapeShowBack.visibility = View.VISIBLE
            } else {
                shapeShowBack.visibility = View.GONE
            }
        }
    }

    fun setSelect(position: Int) {
        selectPosition = position
        notifyDataSetChanged()
    }

}